<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8">
<title th:text="${title}"></title>

<div th:include="/common/layui"></div>
<div th:include="/common/jq"></div>

<!--添加 vue  支持加载-->
<script src="/vue/vue.min.js"></script>
<!--添加 vue  支持加载-->

<style>
.layui-form-item {
	margin-bottom: 3px;
}
</style>
</head>
<body id="app">
	<div style="padding: 10px;" class="layui-form layui-form-pane" action="">
		
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="text"  v-model="name" th:value="${user?.name}"  autocomplete="off"
					placeholder="请输入  帐号" class="layui-input">
			</div>
		</div>
		
		<div th:if="${user==null}" class="layui-form-item">
			<label class="layui-form-label">密码</label>
			<div class="layui-input-block">
				<input type="password"  v-model="pwd" th:value="${user?.pwd}"  autocomplete="off"
					placeholder="请输入  密码" class="layui-input">
			</div>
		</div>
		
		
		<div class="layui-form-item">
			<label class="layui-form-label">真实姓名</label>
			<div class="layui-input-block">
				<input type="text"  v-model="trueName" th:value="${user?.trueName}"  autocomplete="off"
					placeholder="请输入  真实姓名" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
		    <label class="layui-form-label">角色</label>
		    <div class="layui-input-block">
		      <select id="roleId" name="interest" lay-filter="aihao">
		        <option th:value="${role.id}"  th:text="${role.name}"  th:each="role: ${roleList}"></option>
		      </select>
		    </div>
		</div>
		
		<div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">备注</label>
		    <div class="layui-input-block">
		      <textarea placeholder="请输入内容"   v-model="remark"   class="layui-textarea" th:utext="${user?.remark}"></textarea>
		    </div>
	   </div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">排序号</label>
			<div class="layui-input-block">
				<input type="text"  v-model="orderNo" th:value="${user?.orderNo}"  autocomplete="off"
					placeholder="请输入  排序号" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" th:text="${btn_text}"  lay-submit="" lay-filter="demo1"
					onclick="save()"></button>
			</div>
		</div>
		
	</div>
	
</body>

<script th:inline="none">
	layui.use([ 'laydate', 'laypage', 'layer', 'table', 'carousel', 'upload',
			'element','jquery' ], function() {
		var laydate = layui.laydate //日期
		, laypage = layui.laypage //分页
		, layer = layui.layer //弹层
		, table = layui.table //表格
		, carousel = layui.carousel //轮播
		, upload = layui.upload //上传
		, element = layui.element; //元素操作
	});
		
		
	
</script>
<script  th:inline="javascript">
$(function(){
	if("[[${user?.roleId}]]"!="null"){
		$("#roleId").val([[${user?.roleId}]]);
	}
});

	var save_url = [[${save_url}]];
	function save() {
		var index = layer.msg('提交中，请稍候', {
			icon : 16,
			time : false,
			shade : 0.8
		});
		var roleId = $("#roleId").val();
		
		$.post(save_url, {name:app.name,trueName:app.trueName,remark:app.remark,pwd:app.pwd,orderNo:app.orderNo,'role.id':roleId
		}, function(result) {
			if (result.success){
				window.parent.closeDlg(result.msg);
				parent.layui.table.reload('table',{page: {curr: 1}});//刷新父窗口数据
			} else {
				layer.msg(result.msg);
			}
		}, 'json');
	}
	

	
</script>
<script>
	var app = new Vue({
		el : '#app',
		data : {
		}
	});
</script>
</html>